<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <div th:replace="m/head :: head"></div>
    <title>注册-设置</title>
</head>
<body>
<div class="loginwrap">
    <div class="login-title">
        <a href="javascript: window.history.back(-1)">取消</a>
    </div>
    <div class="login-con">
        <h3>设置个人信息</h3>
        <form id="registerForm" th:action="@{/regist/two}" method="post">
            <div class="login-input register-input">
                <div class="login-text clearfix">
                    <div class="left">
                        昵称
                    </div>
                    <div class="right">
                        <input type="text" name="nickname" value="" placeholder="昵称长度为2-6个汉字或3-12个字母数字组合"/>
                    </div>
                </div>
                <div class="login-text">
                    <div class="left">
                        微信
                    </div>
                    <div class="right">
                        <input type="text" name="wechat" value="" placeholder="请填写微信号"/>
                    </div>
                </div>
                <p>为了客服与您便捷沟通，请填写一个有效的微信号</p>
            </div>
            <p class="error" th:text="${error}"></p>
            <input type="submit" class="submit" id="submit-btn" value="提交并完成注册"/>
        </form>
    </div>
</div>
</body>

<div th:replace="m/foot :: footer('baidu.hide')"></div>

<script>
    $(function () {
        $('input').focus(function () {
            setTimeout(function () {
                $('.error').text('');
            }, 1000);
        })

        $('#submit-btn').click(function () {
            if (!Pattern.NICKNAME.test($('input[name="nickname"]').val())) {
                $('.error').text('昵称格式错误');
                return false;
            }

            if (!Pattern.WECHAT.test($('input[name="wechat"]').val())) {
                $('.error').text('微信号格式错误');
                return false;
            }

            window.registerForm.submit();
        })
    })
</script>

</html>
